'''
合同页
'''

from selenium.webdriver.common.by import By
from page.base_page import BasePage


class HtPage(BasePage):
    url="/crm/index.php?m=contract"

    #定位器
    btn_add_ht_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div:nth-child(1) > div > a")
    btn_cat_ht_locator=(By.CSS_SELECTOR,"#form1 > table > tbody > tr:nth-child(1) > td:nth-child(10) > a:nth-child(1)")
    first_select_locator = (By.CSS_SELECTOR, "#form1 > table > tbody > tr:nth-child(1) > td:nth-child(1) > input")
    del_locator = (By.ID, "delete")
    table_element_locator=(By.CSS_SELECTOR,"#form1 > table > tbody")

    def click_add_ht(self):
        '''点击添加合同按钮'''
        self.driver.find_element(*self.btn_add_ht_locator).click()
    def click_cat_ht(self):
        '''点击合同列表中第一个合同合同后面的查看按钮'''
        self.driver.find_element(*self.btn_cat_ht_locator).click()
    def click_first_select(self):
        '''点击合同列表中第一个合同合同前面的选择框'''
        self.driver.find_element(*self.first_select_locator).click()
    def click_del(self):
        '''点击删除'''
        self.driver.find_element(*self.del_locator).click()
    def accept_del(self):
        '''确认删除操作'''
        self.driver.switch_to.alert.accept()

    def get_table_element(self):
        '''获取合同列表的表格对象'''
        return self.driver.find_element(*self.table_element_locator)